<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html>
<head>
    <title>

    </title>
</head>

<body>

<div id="wrapper">
    <div class="gray-bg">
        <div class="row m-t-sm">
        </div>
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                    <div class="tabs-container">
                        <ul class="nav nav-tabs">
                            <li class=""><a  href="${ctx}/medical/sign/edit?id=${signId}">基本信息</a></li>
                            <li class="active" ><a  href="javascript:void(0)">服务包</a></li>
                            <li class=""><a  href="${ctx}/medical/record/list_ecn?ecn=${ecn}&signId=${signId}">服务记录</a></li>
                            <li class=""><a  href="${ctx}/medical/sign/deal/edit?id=${signId}">签约协议</a></li>
                        </ul>
                    </div>
                    <div class="ibox float-e-margins tab-cnt">
                        <div class="ibox-content">
                            <form method="get" data-ajax="${ctx}/admin/pe/packages/list" action="${ctx}/admin/pe/packages/${method}"  class="form-horizontal" id="user_form">
                                <input  type="hidden" id="teamId" name="teamId" value="${teamId}"/>
                                <input  type="hidden" id="signId" name="signId" value="${signId}"/>
                                <input  type="hidden" id="ecn" name="ecn" value="${ecn}"/>

                                <div class="form-group">
                                    <c:if test="${isshow==11}">
                                        <a href="javascript:add_item('', '', '', '' , '' , '');">添加</a>
                                    </c:if>
                                    <div class="table-responsive">
                                        <table class="table table-striped table-bordered table-hover dataTables" id="item-table" style="word-break:break-all;">
                                            <thead>
                                                <tr>
                                                    <th width="14%">服务包名称</th>
                                                    <th width="12%">支付方式</th>
                                                    <th width="12%">服务项数量</th>
                                                    <th width="32%">描述</th>
                                                    <th width="10%">价格（元）</th>
                                                    <th width="10%">创建时间</th>
                                                    <th width="10%">操作</th>
                                                </tr>
                                            </thead>
                                        </table>
                                     </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>
<%--<script src="${ctx}/static/inspinia/js/plugins/layer/layer.js"></script>--%>
<script src="${ctx}/static/inspinia/js/jquery-2.1.1.js"></script>
<script>
    var check_item_ids = [];
    $(document).ready(function() {
        var spcklist = JSON.parse('${data}');
        console.log(spcklist);
        if (spcklist.length > 0){
            for (i in spcklist) {
                addspckItem(spcklist[i].id , spcklist[i].title , spcklist[i].payType , spcklist[i].count , spcklist[i].memo , spcklist[i].defaultPrice , spcklist[i].createTime,spcklist[i].prid );
            }
        }
    });


    function add_item() {
        parent.layer.open({
            type: 2,
            title: '选择服务包',
            shadeClose: true,
            shade: 0.8,
            area: ['1000px', '480px'],
            content: '${ctx}/medical/sign/spck/team/list?teamId=${teamId}&ecn=${ecn}&signId=${signId}'
        });
    }

    function query_item(spckid,prid) {
        if(prid==undefined){
            prid = 0;
        }
        parent.layer.open({
            type: 2,
            title: '查看服务项',
            shadeClose: true,
            shade: 0.8,
            area: ['1000px', '480px'],
            content: '${ctx}/medical/sign/spck/item/lists?teamIds=${teamId}&ecn=${ecn}&signId=${signId}&spckId='+spckid+'&prid='+ prid
        });
    }

    function addspckItem(id,title,payType,count, memo, price , createTime,prid ) {
        var model = $(
                "<tr>" +
                "<td>" + title + "</td>" +
                "<td>" + getGender(payType) + "</td>" +
                "<td>" + count + "</td>" +
                "<td>" + memo + "</td>"+
                "<td>" + price + "</td>"+
                "<td>" + createTime + "</td>"
        );
        model.append("<td><a onclick='query_item(" + id +","+ prid +");'>查看</a></td></tr>");
        $("#item-table").append(model);
        check_item_ids.push(id);
        return true;
    }

    function getGender(code){
        if(code == 1){
            return "公卫";
        }else if(code == 2){
            return "医保";
        }else if(code == 3){
            return "自费";
        }else {
            return "";
        }
    }

    function asdfg() {
        alert("123");
    }

</script>
</body>
</html>
